<?php
if(!empty($_POST) AND !isset($_POST['Entry']))
{
	if($_POST['eagle'] != 0) { UpdateAir('eagle', $_POST['eagle']); }
	if($_POST['eraser'] != 0) { UpdateAir('eraser', $_POST['eraser']); }
	if($_POST['hovercraft'] != 0) { UpdateAir('hovercraft', $_POST['hovercraft']); }
	if($_POST['satellit'] != 0) { UpdateAir('satellit', $_POST['satellit']); }
	if($_POST['shadow'] != 0) { UpdateAir('shadow', $_POST['shadow']); }
}
$result = RequestData('hangar');
$build = RequestData('buildings');
$science = RequestData('forschung');
$ressource = RequestData('resource');
?>
<form method="post">
	<table class="buildings" style="table-layout: fixed; width: 720px;">
		<colgroup>
			<col style="width:115px;">
			<col style="width:auto;">
			<col style="width:100px">
		</colgroup>
		<thead>
			<td>Hangar</td>
		</thead>
			<?php
				$con = Connect();
				$check = mysql_query("SELECT * FROM hangar_build ORDER BY Hangar_LVL");
				while($object = mysql_fetch_object($check))
				{
					$lock = array(false, false, false, false, false, false, false);
					if($build['Hangar'] >= $object->Hangar_LVL)
					{	
						echo '<tr><th><img src="../Game/template/Images/hangar/'.$object->Name.'.png"></th>';
						echo '<th><p>'.$object->Name.'['.$result[$object->Name].']</p><p>'.$object->Description.'</p>';
						echo '<p>Zeit: '.$object->Time.'</p><p>Ben&ouml;tigt: ';
						if($object->Munition != 0)
						{
							if($science['Munition'] < $object->Munition)
							{ 
								echo '<b style="color:#FF0000;"> Munitions Entwicklung Stufe '.$object->Munition.'</b>,'; 
								$lock[0] = true;
							}else{ 
								echo '<b style="color:#00FF00;"> Munitions Entwicklung Stufe '.$object->Munition.'</b>,'; 
							}
						}
						if($object->Panzerung != 0)
						{
							if($science['Panzer'] < $object->Panzerung)
							{ 
								echo '<b style="color:#FF0000;"> Panzer Entwicklung Stufe '.$object->Panzerung.'</b>,'; 
								$lock[1] = true;
							}else{ 
								echo '<b style="color:#00FF00;"> Panzer Entwicklung Stufe '.$object->Panzerung.'</b>,'; 
							}
						}
						if($science['Hydraulik'] < $object->Hydraulik)
						{ 
							echo '<b style="color:#FF0000;"> Hydraulik Stufe '.$object->Hydraulik.'</b>,'; 
							$lock[2] = true;
						}else{ 
							echo '<b style="color:#00FF00;"> Hydraulik Stufe '.$object->Hydraulik.'</b>, '; 
							
						}
						if($science['Maschine'] < $object->Maschinbau)
						{ 
							echo '<b style="color:#FF0000;"> Maschinbau Stufe '.$object->Maschinbau.'</b></p>';
							$lock[3] = true;							
						}else{ 
							echo '<b style="color:#00FF00;"> Maschinbau Stufe '.$object->Maschinbau.'</b></p>'; 
						}
						echo '<p>Ressourcen: ';
						if($ressource['Credits'] < $object->Credits)
						{
							echo '<b style="color:#FF0000;">'.$object->Credits.' Credits</b>, ';
							$lock[4] = true;
						}else{
							echo '<b style="color:#00FF00;">'.$object->Credits.' Credits</b>, ';
						}
						if($ressource['Titan'] < $object->Titan)
						{
							echo '<b style="color:#FF0000;">'.$object->Titan.' Titan</b>, ';
							$lock[5] = true;
						}else{
							echo '<b style="color:#00FF00;">'.$object->Titan.' Titan</b>, ';
						}
						if($ressource['Oel'] < $object->Oel)
						{
							echo '<b style="color:#FF0000;">'.$object->Oel.' &Ouml;l</b>';
							$lock[6] = true;
						}else{
							echo '<b style="color:#00FF00;">'.$object->Oel.' &Ouml;l</b>';
						}
						if($object->Benzin != 0)
						{
							if($ressource['Benzin'] < $object->Benzin)
							{
								echo ', <b style="color:#FF0000;">'.$object->Benzin.' Benzin</b></p></th>';
								$lock[7] = true;
							}else{
								echo ', <b style="color:#00FF00;">'.$object->Benzin.' Benzin</b></p></th>';
							}
						}else{ echo '</p></th>'; }
						echo '<th><p>Einheiten: </p><p><input type="number" name="'.$object->Name.'" value="0" min="0" max="50" style="width:80px;" ';
						if($lock[0] == true || $lock[1] == true || $lock[2] == true || $lock[3] == true || $lock[4] == true || $lock[5] == true || $lock[6] == true || $lock[7] == true) echo 'disabled';
						echo '></p><br><p><input type="submit" name="air"></p></th></tr>';
					}
				}
				Close($con);
			?>
	</table>
</form>